<template>
    <div class="forumContainer">
        <div class="sayAndHole">
            <div class="content">
                <p :style="setActive(!isClick)" @click="gotoMyFood">论坛</p>
                <div class="highlight" :style="setHighlightActive(!isClick)"></div>
            </div>
            <div class="content">
                <p :style="setActive(isClick)" @click="gotoMySport">树洞</p>
                <div class="highlight" :style="setHighlightActive(isClick)"></div>
            </div>
            <div class="publish" @click="gotoPublishSay"></div>
        </div>
        <van-search v-model="value" placeholder="搜点什么" shape="round" background="#F6F8FA"/>
        <keep-alive include="forumSay">
            <router-view></router-view>
        </keep-alive>
    </div>
</template>

<script>
    import { Search } from 'vant';
    export default {
        name:'myForum',
        components:{
            'van-search':Search
        },
        data(){
            return{
                isClick:false,
                value:''
            }
        },
        methods:{
            setActive(isClick){
                return isClick ? 'opacity:1;transform:scale(1.1);' :'opacity:0.3;transform:scale(1);'
            },
            setHighlightActive(isClick){
                return isClick ? 'opacity:1' : 'opacity:0'
            },
            gotoMyFood(){
                if(this.isClick===true){
                    this.$router.replace({
                        name:'say'
                    })
                }
                this.isClick=false
            },
            gotoMySport(){
                if(this.isClick===false){
                    this.$router.replace({
                        name:'hole'
                    })
                }
                this.isClick=true
            },
            gotoPublishSay(){
                this.$router.push({
                    name:'myPublish'
                })
            }
        }
    }
</script>

<style scoped>
    .forumContainer{
        width: 100vw;
        height: 100vh;
        position: relative;
    }
    .sayAndHole{
        width: 100%;
        display: flex;
        justify-content: space-evenly;
    }
    .sayAndHole p{
        font-family: 'PingFangSC-Mediuem';
        font-size: 0.35rem;
        color:#333333;
        margin-top: .88rem;
        opacity: 0.3;
        transition: all 0.5s;
    }
    .content{
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .highlight{
        background-image: url(../assets/img/1-icon@2x/1-33confirmSport/food.png);
        width: 0.32rem;
        height: 0.04rem;
        background-position: center;
        background-size: contain;
        border-radius: 0.02rem;
        margin-top: 0.1rem;
        opacity: 0;
        transition: all 0.5s;
    }
    .publish{
        position: absolute;
        width: .72rem;
        height: .72rem;
        background-image: url(../assets/img/5-icon@2x/5-1publish.png);
        background-position: center;
        background-size: contain;
        top:.88rem;
        right: .32rem;
    }
</style>

<style>
    .van-search__content{
        background-color: #FFF;
    }
</style>